﻿package mortal.game.scene3D.display3d.text3d.staticText3d.filter
{
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.vertexFilters.*;
    import frEngine.shader.filters.vertexFilters.def.*;
    import mortal.game.scene3D.display3d.text3d.staticText3d.*;
    import mortal.game.scene3D.layer3D.utils.*;

    public class SText3DVertexFilter extends VertexFilter
    {
        public static const maxDuringFrame:uint = 30;

        public function SText3DVertexFilter()
        {
            super(-1, null);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            return;
        }// end function

        override public function get programeId() : String
        {
            return "SText3DVertexFilter0";
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:Array = [];
            _loc_3.push(new ToBuilderInfo("vc0-100", "{textPosList}", false, SText3DRender.instance.maxNum, []));
            _loc_3.push(new ToBuilderInfo("vc1", "{textConst1}", false, 1, [100, -1, 500, -1]));
            _loc_3.push(new ToBuilderInfo("vc2", "{textConst2}", false, 1, [Scene3DUtil.cameraAngleCos, Scene3DUtil.cameraAngleSin, TextVo.sw, TextVo.sh]));
            _loc_3.push(new ToBuilderInfo("va0", FilterName.POSITION, false, 3));
            _loc_3.push(new ToBuilderInfo("va1", FilterName.SKIN_INDICES, false, 1));
            _loc_3.push(new ToBuilderInfo("vf0", "{v_textRate}", false, 1));
            _loc_3.push(new ToBuilderInfo("vf1", "{v_textAlpha}", false, 1));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + "mov           vt1    \t\t\t\tvc[va1.x]  \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "frc           vt3.xy    \t\t\tvt1.xy  \t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sub           vt3.zw    \t\t\tvt1.xxxy  \t\tvt3.xxxy\t\t\n";
            _loc_4 = _loc_4 + "slt           vt4.x    \t\t\tvt1.w  \t\t\tvc1.z\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2    \t\t\t\tva0  \t\t\tvt3.zw\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2    \t\t\t\tvt2  \t\t\tvc2.zw\t\t\t\n";
            _loc_4 = _loc_4 + "sge           vt4.y    \t\t\tvt1.w  \t\t\t{vcConst1}.x\t\n";
            _loc_4 = _loc_4 + "mul           vt4.w    \t\t\tvt1.w  \t\t\tvt4.y\t\t\t\n";
            _loc_4 = _loc_4 + "mov           vt0    \t\t\t\tvc[vt4.w]  \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "neg           vt0.w    \t\t\tvt0.w  \t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "frc           vt1.x    \t\t\tvt0.w  \t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sub           vt1.y    \t\t\tvt0.w  \t\t\tvt1.x\t\t\t\n";
            _loc_4 = _loc_4 + "div           vt1.y    \t\t\tvt1.y  \t\t\tvc1.x\t\t\t\n";
            _loc_4 = _loc_4 + "add           vt2.x    \t\t\tvt2.x  \t\t\tvt1.z\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2    \t\t\t\tvt2         \tvt1.y  \t\t\t\n";
            _loc_4 = _loc_4 + "add           {output}    \t\t\tvt0         \tvt2  \t\t\t\n";
            _loc_4 = _loc_4 + "slt           vt4.z    \t\t\tvt0.w  \t\t\tvc1.z\t\t\t\n";
            _loc_4 = _loc_4 + "min           vt4.z    \t\t\tvt4.y      \tvt4.z  \t\t\t\n";
            _loc_4 = _loc_4 + "min           vt4.z    \t\t\tvt4.x      \tvt4.z  \t\t\t\n";
            _loc_4 = _loc_4 + "mul           {output}    \t\t\t{output}      vt4.z  \t\t\t\n";
            _loc_4 = _loc_4 + "mov           {output}.w    \t\t{vcConst1}.z  \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mov           vf0    \t\t\t\tvt3  \t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mov           vf1    \t\t\t\tvt1.x  \t\t\t\t\t\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            param1.OpType = ECalculateOpType.Proj;
            return _loc_4;
        }// end function

    }
}
